package com.hao.rabbitmqproduce.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class ConfirmConfig {
    public static final String EXCHANGE_NAME="boot_confirm_exchange";
    public static final String QUEUE_NAME="boot_confirm";

    @Bean("exchangeConfirm")
    public Exchange exchangeConfirm(){
        return ExchangeBuilder.directExchange(EXCHANGE_NAME).build();
    }

    @Bean("queueConfirm")
    public Queue queueConfirm(){
        return QueueBuilder.durable(QUEUE_NAME).build();
    }

    @Bean
    public Binding confirmBinding(@Qualifier("queueConfirm") Queue queue,@Qualifier("exchangeConfirm") Exchange exchange){
        return BindingBuilder.bind(queue).to(exchange).with("confirm").noargs();
    }

}
